#include "macro.sqf"
/*
	@version: 0.1
	@file_name: fn_sortList.sqf
	@file_author: Tyrghen
	@file_edit: 01/05/2014
	@file_description: Sorts the list of items/weapons
*/
private["_request","_filter","_control","_info","_sort","_order"];
waitUntil {!isNull (findDisplay VAS_Main_Display)};
disableSerialization;
_request = _this select 0;
_filter = _this select 1;
_sort = false;
_order = "ASC";
_text = localize "STR_VAS_Main_VirtGear";
if (count _this > 2) then { _sort = _this select 2; };

if (!_sort) then {
	uiNamespace setVariable["VAS_UI_SORT","NONE"];
} else {
	_order = uiNamespace getVariable["VAS_UI_SORT","NONE"];
	switch (_order) do {
		case "ASC": { _order = "DESC"; _text = localize "STR_VAS_Main_VirtGear_DESC"; };
		default { _order = "ASC"; _text = localize "STR_VAS_Main_VirtGear_ASC"; };
	};
	uiNamespace setVariable["VAS_UI_SORT",_order];
};
diag_log ["sortList",_this,_order];

_control = VAS_getControl(VAS_Main_Display,VAS_virt_list);
lbSort [_control, _order];
ctrlSetText [VAS_Main_vasText, _text];
